import requests
# 使用get方式发送请求
#在地h址栏拼接参数 www.xxx.com/?key1=value1&key2=value2
# {key1:value1}
# Requests除了这种方式，还有可以使用params传参
# # response =requests.get("https://www.baidu.com/s?wd=python")
# data = {'wd':"java"}
# response =requests.get("https://www.baidu.com/s",params=data)
# print(response.ur)
# print(response.text)
# 直接向百度发送求请求，获取不到页面
# 需要添加用户代理放进请求头，则可以正常得到响应
headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko)"
}
rep = requests.get("https://www.baidu.com/",headers=headers)
print(rep.content.decode("utf-8"))